# -*- encoding: utf-8 -*-

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
#User.add_to_class('rol', models.IntegerField(max_length=10, default=0))

class Generos(models.Model):
    class Meta:
        verbose_name_plural = "generos"
    nombre_corto = models.CharField(max_length=100)
    nombre_largo = models.CharField(max_length=300)
    def __unicode__(self):
        return self.nombre_largo
    
class Peliculas (models.Model):
    class Meta:
        verbose_name_plural = "peliculas"
    titulo = models.CharField(max_length=200)
    director = models.CharField(max_length=200)
    actores = models.CharField(max_length=300)
    anyo = models.CharField(max_length=50, verbose_name="año")
    nacionalidad = models.CharField(max_length=100)
    productora = models.CharField(max_length=200)
    genero = models.ForeignKey(Generos)
    sinopsis = models.CharField(max_length=1500)
    url_imagen = models.CharField(max_length=200)
    date_create = models.DateTimeField(auto_now_add=True)
    
    def __unicode__(self):
        return self.titulo

class Valoraciones (models.Model):
    class Meta:
        verbose_name_plural = "valoraciones"
    usuario = models.ForeignKey(User)
    pelicula = models.ForeignKey(Peliculas)
    valoracion = models.IntegerField(max_length=10)
    
    def __unicode__(self):
        return str(self.id)
    
class Amistades(models.Model):
    class Meta:
        verbose_name_plural = "amistades"
    user1 = models.ForeignKey(User, related_name='user1')
    user2 = models.ForeignKey(User, related_name='user2')
    
    def __unicode__(self):
        return str(self.id)
    
class Criticas(models.Model):
    class Meta:
        verbose_name_plural = "criticas"
    usuario = models.ForeignKey(User)
    pelicula = models.ForeignKey(Peliculas)
    titulo = models.CharField(max_length=100)
    contenido = models.CharField(max_length=1000)
    nota = models.ForeignKey(Valoraciones)
    
    def __unicode__(self):
        return self.titulo

    